package Charest;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class demo1 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String name="Charest有很多形式";
        //编码
         byte[] bytes=name.getBytes("GBK");//可以指定编码格式，如getBytes("UTF-8")
         System.out.println(bytes.length);
         System.out.println(Arrays.toString(bytes));
         //解码
        String str=new String(bytes,"GBK");
        System.out.println(str);
    }
}
